package com.ms.content.controller;

import java.util.Arrays;
import java.util.Map;

import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ms.content.entity.AdmsEntity;
import com.ms.content.service.AdmsService;
import com.ms.common.utils.PageUtils;
import com.ms.common.utils.R;



/**
 * 
 *
 * @author wc
 * @email sunlightcs@gmail.com
 * @date 2022-02-23 19:46:27
 */
@RestController
@RequestMapping("content/adms")
public class AdmsController {






    @Autowired
    private AdmsService admsService;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;


    /**
     * 秒杀商品存redis
     */
    @RequestMapping("/mslist")
    public R mslist(@RequestParam Map<String, Object> params) throws InterruptedException {


        R r = admsService.queryPage(params);
        return r;


    }


    /**
     * 列表
     */
//    @RequestMapping("/list")
//    public R list(@RequestParam Map<String, Object> params){
//        PageUtils page = admsService.queryPage(params);
//        return R.ok().put("page", page);
//    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		AdmsEntity adms = admsService.getById(id);

        return R.ok().put("adms", adms);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody AdmsEntity adms){
		admsService.save(adms);
        stringRedisTemplate.delete("goodsList1");
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody AdmsEntity adms){
		admsService.updateById(adms);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		admsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
